package com.example.edu.Controller;

import com.example.edu.Dto.*;
import com.example.edu.Entity.Article;
import com.example.edu.Service.ArticleService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/admin/article")
public class ArticleController {
    @Resource
    ArticleService articleService;

    @PostMapping("/create")
    public Result create(@RequestHeader("Authorization") String token, @RequestBody CreateArticleDto createDraftDto){
        return articleService.create(token,createDraftDto);
    }

    @PostMapping("/delete")
    public Result delete(@RequestHeader("Authorization") String token, @RequestBody Article article_id){
        return articleService.delete(token,article_id);
    }

    @PostMapping("/update")
    public Result update(@RequestHeader("Authorization") String token, @RequestBody UpdateArticleDto updateDraftDto){
        return articleService.update(token,updateDraftDto);
    }

    @PostMapping("/getList")
    public Result getList(@RequestHeader("Authorization") String token, @RequestBody PageDto pageDto){
        return articleService.getList(token,pageDto);
    }

    @PostMapping("/get")
    public Result get(@RequestBody Article article_id){
        return articleService.get(article_id);
    }

    @PostMapping("/save")
    public Result save(@RequestHeader("Authorization") String token, @RequestBody SaveDto saveDto){
        return articleService.save(token,saveDto);
    }

    @PostMapping("/recall")
    public Result recall(@RequestBody Article article_id){
        return articleService.recall(article_id);
    }

    @PostMapping("/getTags")
    public Result getTags(@RequestHeader("Authorization") String token){
        return articleService.getTags(token);
    }

    @PostMapping("/search")
    public Result search(@RequestHeader("Authorization") String token, @RequestBody UnionSearchDto unionSearchDto){
        return articleService.search(token,unionSearchDto);
    }
}
